import request from '@/utils/request'

export const getRoleAll = data => {
  return request({
    method: 'POST',
    url: '/boss/role/getRolePages',
    data
  })
}

export const deleteRole = id => {
  return request({
    method: 'DELETE',
    url: '/boss/role/' + id
  })
}

export const addRole = data => {
  return request({
    method: 'POST',
    url: '/boss/role/saveOrUpdate',
    data
  })
}

export const getRoleById = id => {
  return request({
    method: 'GET',
    url: '/boss/role/' + id
  })
}

export const getAllRoles = () => {
  return request({
    method: 'GET',
    url: '/boss/role/all'
  })
}

export const setAllocRoles = data => {
  return request({
    method: 'POST',
    url: '/boss/role/allocateUserRoles',
    data
  })
}

export const getUserRoles = userId => {
  return request({
    method: 'GET',
    url: '/boss/role/user/' + userId
  })
}

export const getRolesList = roleId => {
  return request({
    method: 'GET',
    url: '/boss/resource/getRoleResources',
    params: {
      roleId
    }
  })
}

export const updateRolesList = data => {
  return request({
    method: 'POST',
    url: '/boss/resource/allocateRoleResources',
    data
  })
}
